/*

  Copyright (c) 2021 前海飞算云智软件科技（深圳）有限公司

  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  
*/

package com.feisuanyz.component.zip.enums;

import lombok.Getter;

/**   
 * <p>
 *   压缩文件格式
 * </p>
 * @author 飞算云智
 * @date 2020-06-19 18:28
 */
@Getter
public enum ZipFormat {
	/**
	 * 压缩文件格式
	 */
	ZIP(".zip", "ZIP压缩文件"),
	RAR(".rar", "RAR压缩文件"),
	TAR_GZ(".tar.gz", "TAR.GZ压缩文件")
	;
	
	private String ext;
    private String desc;
    
	private ZipFormat(String ext, String desc) {
		this.ext = ext;
		this.desc = desc;
	}
	
	/** 
	 * <p>
	 * 	 通过扩展名查询枚举值
	 * </p>
	 * @param ext
	 * @return ZipFormat 
	 */
	public static ZipFormat parse(String ext) {
        for (ZipFormat zf : values()) {
            if (zf.ext.equals(ext)) {
                return zf;
            }
        }
        return null;
    }
    
}
